/**
 * 
 */
package robocup.component.tactics;

import java.util.EnumMap;



/**
 * @author Thomas Karbe
 *
 */
public class StateCache {

  // map containing booleans
  public EnumMap<BOOLEANS, Boolean> booleanMap = new EnumMap<BOOLEANS, Boolean>(
                                                   BOOLEANS.class);    

  // boolean - Values
  public enum BOOLEANS {
    MY_BALL,
    PLAYER_HAS_BALL
  }

  // the unknown values
  public final static Boolean BOOLEAN_UNKNOWN = null;
  
  public StateCache() {
    resetAll();
  }
  
  public final void resetAll() {
    for (final BOOLEANS b : BOOLEANS.values()) {
      this.booleanMap.put(b, StateCache.BOOLEAN_UNKNOWN);
    }
  }

  /**
   * Sets the boolean value b for bEnum.
   * 
   * @param bEnum -
   *          key
   * @param b -
   *          value
   */
  public void set(final BOOLEANS bEnum,
      final boolean b) {

    this.booleanMap.put(bEnum, Boolean.valueOf(b));
  }

  /**
   * Returns the value for a given key (bEnum). (Bool Version)
   * 
   * @param bEnum -
   *          key
   * @return the Boolean belonging to the key (null if unknown)
   */
  public Boolean get(final BOOLEANS bEnum) {

    return this.booleanMap.get(bEnum);
  }
}